const state = {
  portName: localStorage.getItem('portName') || '',
  roleName: localStorage.getItem('roleName') || '',
  roleId: localStorage.getItem('roleId') || '',
  roleOptions: localStorage.getItem('roleOptions') || [],
  sysProjectCode: localStorage.getItem('sys-project-code') || '',
}

const mutations = {
  // portName
  setState(state, payload) {
    state.portName = payload
    localStorage.setItem('portName', payload)
  },
  removeState(state, payload) {
    state.portName = ''
    localStorage.removeItem('portName')
  },
  // roleName
  setRoleName(state, payload) {
    state.roleName = payload
    localStorage.setItem('roleName', payload)
  },
  removeRoleName(state, payload) {
    state.roleName = ''
    localStorage.removeItem('roleName')
  },
  // roleId
  setRoleId(state, payload) {
    state.roleId = payload
    localStorage.setItem('roleId', payload)
  },
  removeRoleId(state, payload) {
    state.roleId = ''
    localStorage.removeItem('roleId')
  },
  // roleOptions
  setRoleOptions(state, payload) {
    state.roleOptions = payload
    localStorage.setItem('roleOptions', payload)
  },
  removeRoleOptions(state, payload) {
    state.roleOptions = ''
    localStorage.removeItem('roleOptions')
  },
  // sysProjectCode
  setSysProjectCode(state, payload) {
    state.sysProjectCode = payload
    localStorage.setItem('sys-project-code', payload)
  },
  removeSysProjectCode(state, payload) {
    state.sysProjectCode = ''
    localStorage.removeItem('sys-project-code')
  },
}

const actions = {}

export default {
  namespaced: true,
  state,
  mutations,
  actions,
}
